package com.globallogic.draw;

import com.globallogic.drawutils.UndoRedo;
import com.globallogic.inout.Out;

public abstract class DrawObject implements Drawable, Comparable<DrawObject> {

	public abstract int getLenght();

	@Override
	public int compareTo(DrawObject o) {

		return (this.getLenght() - o.getLenght());
		
	}

	@Override
	public void draw(float scale, int slotLenght) {
        
		int lenght;
		int spaceBefor;
		
        StringBuilder sb = new StringBuilder();
        
        lenght = (int) (getLenght() * scale);
        spaceBefor = (int) ((slotLenght - lenght) / 2);
        
        for (int i = 0; i < spaceBefor; i ++) {

        	sb.append(" ");
        	
        }
        
        for (int i = 0; i < lenght; i ++) {

        	sb.append(drawChar);
        	
        }
		
        Out.printLn(sb.toString());

	}
	
	public int getX0() {
		
		return x0.getValue();
	
	}

	public void setX0(int x0) {

		this.x0.setValue(x0);
		
	}

	public int getY0() {
		
		return y0.getValue();
	
	}

	public void setY0(int y0) {

		this.y0.setValue(y0);
		
	}
	
	protected char drawChar;
	
	private UndoRedo<Integer> x0;
	private UndoRedo<Integer> y0;
	
}
